package com.liuhe.collections.test1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Test3 {
    public static void main(String[] args) {
        //随机抽取学生
        //只能点一次
        //点完开始第二次点名
        ArrayList<String> list = new ArrayList<>();
        ArrayList<String> list2 = new ArrayList<>();

        //添加数据
        Collections.addAll(list, "jack", "tom", "mary", "joker", "bateMan");
        Random r = new Random();
        for (int j = 0; j < 10; j++) {
            System.out.println("-----------" + j + "------------");
            //获取到集合长度
            int size = list.size();
            //进行遍历
            for (int i = 0; i < size; i++) {
                int index = r.nextInt(list.size());
                //抽到后进行删除
                String name = list.get(index);
                list.remove(name);
                list2.add(name);
                System.out.println(name);
            }

            //抽取完进行第二随机
            list.addAll(list2);
            list2.clear();
        }

    }
}
